#include "TSearchLineEdit.h"

TSearchLineEdit::TSearchLineEdit(QWidget *parent) :
    TLineEdit(parent)
{
    _menuLabel = new QLabel(this);

    _menuLabel->setPixmap(QPixmap(":/widgets/images/magnifier.png"));
    _menuLabel->installEventFilter(this);

    int height = minimumSizeHint().height();
    QString sheet = QLatin1String("QLineEdit{ padding-left: ");
    sheet += QString::number(_menuLabel->pixmap()->width() + 6);
    sheet += QLatin1String(";}");
    setStyleSheet(sheet);
    // Little hack. Somehow style sheet makes widget short. Put back height.
    setMinimumHeight(height);
}

//void TSearchLineEdit::resizeEvent(QResizeEvent *)
//{
//    positionMenuLabel();
//}

//void TSearchLineEdit::positionMenuLabel()
//{
//  _menuLabel->setAlignment(Qt::AlignVCenter | Qt::AlignRight);
//  _menuLabel->setStyleSheet("QLabel { margin-left:6}");

//  _menuLabel->setGeometry(width() - _menuLabel->pixmap()->width() - 6, 0,
//                          _menuLabel->pixmap()->width() + 6, height());
//}
